package com.anycl.customer.advice;

import com.anycl.customer.exception.CustomerException;
import com.anycl.customer.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(value = CustomerException.class)
    public CommonResponse<String> handlerCustomerException(HttpServletRequest req,
                                                           CustomerException e) {
        CommonResponse<String> response = new CommonResponse<>(-1, "business error");
        response.setData(e.getMessage());
        return response;
    }


}
